package blokucbl;

import java.util.Observer;

public class CDamier {
	VDamier damierViewer;
	Damier damier;
	Object parent;
	
	public CDamier(Object parent) {
		this.damierViewer = new VDamier();
		this.damier = new Damier((Observer)this.damierViewer);
		this.parent = parent;
	}

	public VDamier getDamierViewer() {
		return damierViewer;
	}

	public void setDamierViewer(VDamier damierViewer) {
		this.damierViewer = damierViewer;
	}

	public Damier getDamier() {
		return damier;
	}

	public void setDamier(Damier damier) {
		this.damier = damier;
	}
	
    public void focusPanel(int x, int y) {
        
        //effacerPassageSouris(); 
         
        //System.out.println(x + " " + y);
         
        boolean[] piece = jeu.getPieceCourante().getMatrice();
        
        int xc, yc; // positions sur le damier
        
        for (int i = 0; i < 25; i++) {
            
            if (piece[i]) {
               //System.out.println("point : " + i%5 + " " + i/5); // position indépendante de la pèice
               xc =  x - 2 + i%5;
               yc = y - 2 + i/5;
               
               //System.out.println("coord : " + xc + " " + yc); // projection sur le damier
               
               if (xc >=0 && xc < damier.getWidth() && yc >=0 && yc < damierViewer.getWidth()) {
                   
                   damierViewer.getCase(xc, yc).passageSouris();
                   
               }
               
                
            }
            
            
        } 
         
         
         
     }	

}
